package com.ruoyi.system.api.domain;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.annotation.Excel.ColumnType;
import com.ruoyi.common.core.web.domain.BaseEntity;

/**
 * 角色表 sys_role
 * 
 * @author ruoyi
 */
@ApiModel(value = "角色表")
@Data
@EqualsAndHashCode(callSuper = true)
public class SysRole extends BaseEntity {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "角色ID")
    @Excel(name = "角色序号", cellType = ColumnType.NUMERIC)
    private Long roleId;

    @ApiModelProperty(value = "角色名称")
    @Excel(name = "角色名称")
    private String roleName;

    @ApiModelProperty(value = "角色权限")
    @Excel(name = "角色权限")
    private String roleKey;

    @ApiModelProperty(value = "角色排序")
    @Excel(name = "角色排序")
    private String roleSort;

    @ApiModelProperty(value = "数据范围(1: 所有数据权限；2: 自定义数据权限；3: 本部门数据权限；4: 本部门及以下数据权限)")
    @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限")
    private String dataScope;

    @ApiModelProperty(value = "菜单树选择项是否关联显示(0: 父子不互相关联显示 1: 父子互相关联显示)")
    private boolean menuCheckStrictly;

    @ApiModelProperty(value = "部门树选择项是否关联显示(0: 父子不互相关联显示 1: 父子互相关联显示)")
    private boolean deptCheckStrictly;


    @ApiModelProperty(value = "角色状态(1正常 0停用")
    @Excel(name = "角色状态", readConverterExp = "1=正常,0=停用")
    private String status;

    @ApiModelProperty(value = "删除标志(0代表存在 2代表删除)")
    private String delFlag;

    @ApiModelProperty(value = "用户是否存在此角色标识 默认不存在")
    private boolean flag = false;

    @ApiModelProperty(value = "菜单组")
    private Long[] menuIds;

    @ApiModelProperty(value = "部门组(数据权限)")
    private Long[] deptIds;

    public SysRole() {
    }

    public SysRole(Long roleId)
    {
        this.roleId = roleId;
    }

    public Long getRoleId()
    {
        return roleId;
    }

    public void setRoleId(Long roleId)
    {
        this.roleId = roleId;
    }

    public boolean isAdmin() {
        return isAdmin(this.roleId);
    }

    public static boolean isAdmin(Long roleId) {
        return roleId != null && 1L == roleId;
    }

    @NotBlank(message = "角色名称不能为空")
    @Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符")
    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    @NotBlank(message = "权限字符不能为空")
    @Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符")
    public String getRoleKey() {
        return roleKey;
    }

    public void setRoleKey(String roleKey) {
        this.roleKey = roleKey;
    }

    @NotBlank(message = "显示顺序不能为空")
    public String getRoleSort() {
        return roleSort;
    }

    public void setRoleSort(String roleSort) {
        this.roleSort = roleSort;
    }

}
